package  loader
{
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import events.MyEvent;
	import flash.events.Event;
	/**
	 * ...
	 * @author FireKnight
	 */
	public class EmbedSwfLoader extends EventDispatcher 
	{
		private var _swfName:String;
		public const SWFLOADED:String = "swfloaded";
		private var swfLoader:Loader=new Loader();
		public function EmbedSwfLoader(target:IEventDispatcher=null) 
		{
			super(target);
			
		}
		
		public function loadSwf(target:*, flag:String):void
		{
			_swfName = flag;
			swfLoader.loadBytes(target)
			swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,handleSwfLoaded)
		}
		
		private function handleSwfLoaded(e:Event):void
		{
			this.dispatchEvent(new MyEvent(SWFLOADED, [swfLoader.content, _swfName]));
			swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,handleSwfLoaded)
		}
		
		
		
	}

}